//二叉树最大路径和
public class TreeMaxRoadSum {
}
class TreeMaxRoadSumSolution {
    int ret = Integer.MIN_VALUE;

    public int maxPathSum(TreeNode root) {
        process(root);
        return ret;
    }

    int process(TreeNode root) {
        if (root == null) return 0;
        int left = Math.max(0, process(root.left));
        int right = Math.max(0, process(root.right));
        ret = Math.max(ret, left + right + root.val);
        return root.val + Math.max(left, right);
    }
}